#include "driver/gpio.h"
#include "driver/i2c_master.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "ssd1306.h"

void app_main(void)
{

    esp_err_t ret;
    i2c_master_bus_config_t bus_config = {
        .i2c_port = I2C_NUM_0,
        .clk_source = I2C_CLK_SRC_DEFAULT,
        .scl_io_num = GPIO_NUM_22,
        .sda_io_num = GPIO_NUM_21,
        .flags = {
            .enable_internal_pullup = true}};
    i2c_master_bus_handle_t bus_handle;
    ret = i2c_new_master_bus(&bus_config, &bus_handle);

    if (ret == ESP_OK)
    {
        ESP_LOGI("I2C", "I2C bus created successfully");
    }
    else
    {
        ESP_LOGE("I2C", "I2C bus creation failed");
    }

    ssd1306_init_with_bus(bus_handle);

    ssd1306_draw_rect(10, 10, 128, 64);

    ssd1306_update();

    while (1)
    {
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}